﻿using Engine;
using Engine.Graphics;
using Game;

namespace SAGhoul.Blocks
{
    public class SAGBrokenArtifactBlock : Block
    {
        public BlockMesh m_handleMesh = new();
        private Texture2D m_texture;

        public override void Initialize()
        {
            m_texture = ContentManager.Get<Texture2D>("Textures/Trophy");
            Model model = ContentManager.Get<Model>("Models/SAGArtifact");
            Matrix transform_Handle = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Handle").ParentBone) * Matrix.CreateTranslation(0f, -0.6f, 0f);
            m_handleMesh.AppendModelMeshPart(model.FindMesh("Handle").MeshParts[0], transform_Handle, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.Gray);

            Matrix transform_Ring = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Ring").ParentBone) * transform_Handle;
			m_handleMesh.AppendModelMeshPart(model.FindMesh("Ring").MeshParts[0], transform_Ring, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.Gray);

            base.Initialize();
        }

        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_handleMesh, m_texture, color, 2f * size, ref matrix, environmentData);
        }

		public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
        }

    }
}
